<?php

class BuronanController extends Controller
{
	/**
	 * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
	 * using two-column layout. See 'protected/views/layouts/column2.php'.
	 */
	public $layout='//layouts/column2';

		public function actionView($id)
			{
				$this->render('view',array(
					'model'=>$this->loadModel($id),
				));
			}

		public function loadModel($id)
		{
			$model=Buronan::model()->findByPk($id);
			if($model===null)
				throw new CHttpException(404,'The requested page does not exist.');
			return $model;
		}	

		public function actionList()
        {
                $session=new CHttpSession;
                $session->open();		
                $criteria = new CDbCriteria();            

                $model=new Buronan('search2');
                $model->unsetAttributes();  // clear any default values

                if(isset($_GET['Buronan']))
		{
                        $model->attributes=$_GET['Buronan'];
			
			
                   	
                       if (!empty($model->nama)) $criteria->addCondition('nama = "'.$model->nama.'"');
                     
                    	
                       if (!empty($model->warganegara)) $criteria->addCondition('warganegara = "'.$model->warganegara.'"');
                     

                       if (!empty($model->kejahatan)) $criteria->addCondition('kejahatan = "'.$model->kejahatan.'"');
                     
                     
                    			
		}
                 $session['Buronan_records']=Buronan::model()->findAll($criteria); 
       

                $this->render('list',array(
			'model'=>$model,
		));
        }


     




	/**
	 * Performs the AJAX validation.
	 * @param CModel the model to be validated
	 */
	protected function performAjaxValidation($model)
	{
		if(isset($_POST['ajax']) && $_POST['ajax']==='posting-form')
		{
			echo CActiveForm::validate($model);
			Yii::app()->end();
		}
	}
        
}
